package com.tanhua.server.exceptions;

import com.tanhua.domain.vo.ErrorResult;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 统一异常处理器
 */
@ControllerAdvice
public class ExceptionAdvice {

    //定义该方法处理那种类型的异常
    @ExceptionHandler(Exception.class)
    public ResponseEntity handlerException(Exception e){
        e.printStackTrace();
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(ErrorResult.error());
    }
}
